IF exists(SELECT * FROM dbo.sysobjects WHERE name='WEB_rapportPeriode' AND xtype='FN') 
BEGIN
	DROP FUNCTION WEB_rapportPeriode
END
GO

create function WEB_rapportPeriode(@klas varchar(5),@periode int)
returns char(1)
as
begin
declare @jaar int
declare @res int
set @jaar = left(@klas,1)
set @res = @periode
if (@jaar = '5') and (@periode = 4) set @res = 3
if (@jaar = '5') and (@periode = 5) set @res = 4
if (@jaar = '6') and (@periode = 5) set @res = 3
return @res
end